<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core">
  
    <p:panel header="Campañas SMS" style="border: none;">
        <div align="center">
            <p><h:outputText value="REGISTRO DE EMPRESAS" class="title"/></p>
            <h:form id="RegisterCompany">
                <h:panelGrid columns="4"  >
                    <h:outputText value="Nombre"/>
                    <p:inputText value="#{companyBean.company.name}"/>

                    <h:outputText value="Nombre corto"/>
                    <p:inputText value="#{companyBean.company.shortName}"/>

                    <h:outputText value="Correo"/>
                    <p:inputText value="#{companyBean.company.email}"/>

                    <h:outputText value="Telefono"/>
                    <p:inputText value="#{companyBean.company.phone}" required="true" label="Telefono"/>

                    <h:outputText value="DireccionWeb"/>
                    <p:inputText value="#{companyBean.company.webSite}"/>

                    <h:outputText value="pais"/>
                    <p:inputText value="#{companyBean.company.idCountry}"/>

                    <h:outputText value="departamento"/>
                    <p:inputText value="#{companyBean.company.idDepartment}"/>

                    <h:outputText value="provincia"/>
                    <p:inputText value="#{companyBean.company.idProvince}"/>

                    <h:outputText value="distrito"/>
                    <p:inputText value="#{companyBean.company.idDistrict}"/>

                    <h:outputText value="Representante"/>
                    <p:inputText value="#{companyBean.company.representative}"/>

                </h:panelGrid>
                <br/>
                <p:commandButton value="GUARDAR" action="#{companyBean.saveCompany}" update="@form,:formListCompany:datosEmpresa" icon="ui-icon-disk"/>

            </h:form>
        </div>

        <br/>
        <div align="center">
            <p><h:outputText value="LISTA DE EMPRESAS" class="title"/></p>
            <h:form id="formListCompany">
                <p:dataTable value="#{companyBean.listCompany}" var="company" id="datosEmpresa" >
                    <!--column for edit-->
                    <p:column headerText="OPCIONES"> 
                        <p:menuButton value=" ">
                            <p:menuitem value="Editar" icon="ui-icon-image" update=":RegisterCompany">
                                <f:setPropertyActionListener value="#{company}" target="#{companyBean.company}"/>
                            </p:menuitem>
                            <p:menuitem value="Eliminar" icon="ui-icon-image" action="#{companyBean.deleteCompany}" update="@form">
                                <f:setPropertyActionListener value="#{company}" target="#{companyBean.company}"/>
                            </p:menuitem>
                        </p:menuButton>
                    </p:column>
                    <!--column for delete-->
                    <p:column headerText="NOMBRE"> 
                        <h:outputText value="#{company.name}"/>
                    </p:column>

                    <p:column headerText="WEBSITE"> 
                        <h:outputText value="#{company.webSite}"/>
                    </p:column>

                    <p:column headerText="TELEFONO"> 
                        <h:outputText value="#{company.phone}"/>
                    </p:column>

                    <p:column headerText="REPRESENTANTE"> 
                        <h:outputText value="#{company.representative}"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>

    </p:panel>
</ui:composition>
